//
//  YSCategoryDataTool.m
//  Yueshi
//
//  Created by Northwan on 15/9/7.
//  Copyright (c) 2015年 悦食中国. All rights reserved.
//

#import "YSCategoryDataTool.h"

@implementation YSCategoryDataTool
+(void)getCategoryInfo:(void (^)(YSCategoryRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [self postWithUrl:[NSString stringWithFormat:@"%@product/category",BASE_URL] param:params hasT:NO resultClass:[YSCategoryRes class] success:success failure:failure];
}

+(void)getProductList:(NSInteger)entryId type:(NSInteger)type pageIndex:(NSInteger)pageIndex sortFile:(NSString *)sortFile seque:(NSString *)seque success:(void (^)(YSProductListRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:entryId] forKey:@"entryId"];
    [params setObject:[NSNumber numberWithInteger:type] forKey:@"type"];
    [params setObject:sortFile forKey:@"sortFile"];
    [params setObject:seque forKey:@"seque"];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKey:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@product/productList",BASE_URL] param:params hasT:NO resultClass:[YSProductListRes class] success:success failure:failure];
}

+(void)getBusinessWithSupplierId:(NSInteger)supplierId pageIndex:(NSInteger)pageIndex success:(void (^)(YSBusinessRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:supplierId] forKey:@"supplierId"];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKey:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@product/business",BASE_URL] param:params hasT:NO resultClass:[YSBusinessRes class] success:success failure:failure];
}

+ (void)searchThinkKeysWithParam:(NSString *)keywords success:(void (^)(SearchThinkKeys *result))success failure:(void (^)(NSError *error))failure{
      NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:keywords forKey:@"keywords"];
    [self postWithUrl:[NSString stringWithFormat:@"%@product/think",BASE_URL] param:params hasT:NO resultClass:[SearchThinkKeys class] success:success failure:failure];
}

+ (void)searchProductDataWithKeyWords:(NSString *)keyWords pageIndex:(NSInteger)pageIndex success:(void (^)(ProductSearch *result))success failure:(void (^)(NSError *error))failure{
      NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:keyWords forKey:@"keywords"];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKeyedSubscript:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@product/search",BASE_URL] param:params hasT:NO resultClass:[ProductSearch class] success:success failure:failure];
}

+ (void)searchDataWithKeywords:(NSString *)keywords searchType:(NSInteger)searchType pageIndex:(NSInteger)pageIndex success:(void (^)(YSSearchRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:keywords forKey:@"keywords"];
    [params setObject:[NSNumber numberWithInteger:searchType] forKeyedSubscript:@"searchType"];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKeyedSubscript:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@appIndex/search",BASE_URL] param:params hasT:NO resultClass:[YSSearchRes class] success:success failure:failure];
}

+(void)loadVipList:(NSInteger)pageIndex success:(void (^)(YSVipCategorieRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKeyedSubscript:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@vip/list",BASE_URL] param:params hasT:YES resultClass:[YSVipCategorieRes class] success:success failure:failure];
}

+(void)validVipCode:(NSString *)code success:(void (^)(BaseResponse *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:code forKey:@"code"];
    [self postWithUrl:[NSString stringWithFormat:@"%@vip/invitationCode",BASE_URL] param:params hasT:YES resultClass:[BaseResponse class] success:success failure:failure];
}

+(void)loadVipServiceDetail:(NSInteger)advertId success:(void (^)(YSVipServiceDetailRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:advertId] forKey:@"advertId"];
    [self postWithUrl:[NSString stringWithFormat:@"%@vip/details",BASE_URL] param:params hasT:YES resultClass:[YSVipServiceDetailRes class] success:success failure:failure];
}

@end
